import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';

import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { PlayCountPipe } from './pipes/play-count.pipe';
import { SingleSheetComponent } from './single-sheet/single-sheet.component';
//配置i18n
export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    PlayCountPipe,
    SingleSheetComponent
  ],
  imports: [
    CommonModule,
    IonicModule,
    FormsModule,
    HttpClientModule,
    TranslateModule.forRoot({//配置i18n
      loader: {
        provide: TranslateLoader,
        useFactory: createTranslateLoader,
        deps: [HttpClient]
      }
    })
  ],
  exports: [
    CommonModule,
    IonicModule,
    FormsModule,
    TranslateModule,
    PlayCountPipe,
    SingleSheetComponent
  ],
  providers: []
})
export class ShareModule {
  constructor(private i18l: TranslateService) {
    this.i18l.use('zh_CN')
  }
}
